package com.cw.demo.bootstrap;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

@Configuration
public class I18nConfig {

  @Value(value = "${spring.messages.basename}")
  private String basename;
  @Value(value = "${spring.messages.encoding}")
  private String encoding;

  @Bean(name = "messageSource")
  public ResourceBundleMessageSource resourceBundleMessageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename(basename);
    messageSource.setDefaultEncoding(encoding);
    return messageSource;
  }
}

